 
 function querenzhifuss(){  //会员的购买方式
 	
 	 var val=$('input:radio[name="radio1"]:checked').val();
	     if(val==null){
	     	alert("未选择支付方式");
	     	return false;
	     }else{
	     	 if(val=="01"){
                yuezhifu();	 	
	     	 }else if(val=="02"){
	     	 	callpay();
	     	 }
	     }
 }
zhanghuxinxi();
function  zhanghuxinxi(){
   	$.ajax({
		url: urlcore + "/api/userAccount/selectUserAccountDetails",
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success:function(data){
			if (data.success == true) {
				$("#zhifudinge").html("&yen;"+data.data.balanceMoney);
			}else{
				alert(data.msg);
			}
		},
		error:function() {
			/* Act on the event*/
			alert("error");
		}
	});	
}


//微信支付
function zhifuweixin(){
	   if(uuuuid!=""){
	   	
	   var jinge=$("#jinge").val();
		    if(jinge>1){
	   
	   	$.ajax({
					url: urlcore+"/api/pay/wxpay2?userId="+uuuuid+"&isPayThaw=1&cashMoney="+jinge,
					type: "get",
					dataType: 'json',
					contentType: "application/json;charset=utf-8",
					success:function(data){		
					var d = data.data;
					 WeixinJSBridge.invoke(
					    'getBrandWCPayRequest',
					    {
				           "appId":d.appId,    
				           "timeStamp":d.timeStamp,        
				           "nonceStr":d.nonceStr, 
				           "package":d.package,     
				           "signType":"MD5",        
				           "paySign":d.paySign 
				       },
					    function (res){
					         if(res.err_msg == "get_brand_wcpay_request:ok" ) {
					         	  window.location.href="../index.html";
					         }else{
					         	alert("支付失败");
					         }
					    });
				},
					error:function() {
						/* Act on the event */
						alert("error");
					}
				});
						
	   	}
	   }
				
	
        }



 function callpay(){
		if (typeof WeixinJSBridge == "undefined"){
			    if (document.addEventListener){
		document.addEventListener('WeixinJSBridgeReady', zhifuweixin,false);
			    }else if (document.attachEvent){
        document.attachEvent('WeixinJSBridgeReady', zhifuweixin);
		document.attachEvent('onWeixinJSBridgeReady', zhifuweixin);
			    }
			    }else{
			        zhifuweixin();
			    }
			}
 
 


//余额支付
function yuezhifu(){
	if(uuuuid!=""){
		  var jinge=$("#jinge").val();
		    if(jinge>1){
	 $.ajax({
		url: urlcore + "/api/user/selectUserInfoByUserId?id="+uuuuid,
		type: "get",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
				
				if(data.data!=null && data.data!=""){
					if(data.data.payPwd!="" || data.data.payPwd!=null){
		               sessionStorage.setItem("orids","");
	                   sessionStorage.setItem("hid","");
	                   sessionStorage.setItem("tid","");
	                    sessionStorage.setItem("qian","");
	                   sessionStorage.setItem("chengxin",jinge);
		window.location.href="zhifumimatankuang.html";
					}else{
						alert("未设置支付密码");
	             window.location.href="../buy/12.7.0shezhi.html";
					}
				}
			}
		},
		error: function() {
			/* Act on the event */
			alert("error");
		}
	});
		 	
		    }
	}else{
		window.location.href="../gotoindex.html";
	}
}


